
layui.define(['index', 'layer', 'form', 'table', 'laypage', 'layedit', 'laydate'], function (exports) {



    var $ = layui.$;
    var laypage = layui.laypage;
    var form = layui.form;
    var layer = layui.layer;

    laypage.render(zmnPage.laypageOptions(json));

    form.render();

    var textarea_content = '';
    var hasDatas = json.hasDatas;
    if(hasDatas){
        var currentActivityId = json.currentActivityId;
        var desc = json.detail.desc;
        var content = '';
        if(desc){
            content = desc.content;
            textarea_content = desc.content;
        }
        var oldData = {
            "activityId": currentActivityId
            ,"content": content
        };

        form.val("act-modify-description-form", oldData);
    }

    ue.ready(function () {
        ue.execCommand('insertHtml', textarea_content);
    });



    form.on('submit(act-modify-description-submit)', function (obj) {
        var editorContent = getContent();
        var data = {
            activityId: json.currentActivityId,
            content : editorContent
        };

        $("#act-modify-description-submit").addClass('layui-disabled').prop("disabled", true);
        $.ajax({
            type: "POST",
            url: "/activity/config/modify-description",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(data),
            success: function (res) {
                if (res.status == 200) {
                    // 不关闭
                    // zmnLayUtil.closeThisIframeMsg(parent, res.message, "zmn-activity-table");
                    layer.msg('保存成功!');
                }else{
                    layer.msg(res.message, {icon: 5, shift: 6});
                }
                $("#act-modify-description-submit").removeClass('layui-disabled').prop("disabled", false);
                return false;
            }
        });
        return false;
    });


    $(document).on('click', '#act-modify-description-cancel', function () {
        zmnLayUtil.closeThisIframeMsg(parent, null, null);
    });
    //对外暴露的接口
    exports('zmn_plat_activity_modifyDescription', {});
});

